﻿
using dbapi_lib.API.Plugin;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace Handball_plugin_lib
{
    [Export(typeof(ElderPlugin))]
    public class HandballPlugin : ElderPlugin
    {
        PlayerDAO playerDao;
        TeamDAO teamDao;

        public HandballPlugin()
        {
            playerDao = new PlayerDAO();
            teamDao = new TeamDAO();

            
        }

        public void createtable()
        {
            teamDao.createTable();
        }

        public int createTeam(String name, DateTime founded, Boolean isBanned)
        {
            TeamMO team = new TeamMO();
            team.name = name;
            team.isbanned = isBanned;
            team.founded = founded;

            int id = teamDao.insertReturnPK(team);
            team.id = id;

            return id;
        }

        public String getTeam(int id)
        {
            TeamMO mo = teamDao.findById(id);

            StringBuilder b = new StringBuilder(200);
            b.Append(mo.id + ", " + mo.name + ", " + mo.founded + ", " + mo.isbanned);
            return b.ToString();
        }

    }
}
